#define _CRT_SECURE_NO_WARNINGS 1

#define _CRT_SECURE_NO_WARNINGS 1

#define MAXSIZE 10 
#include <stdio.h>
#include <stdlib.h>

typedef struct
{
	int* elem;
	int* before;
	int length;
}Sqlist;

void Init(Sqlist& L)
{
	L.elem = (int*)malloc(sizeof(int) * MAXSIZE);
	L.before = (int*)malloc(sizeof(int) * MAXSIZE);
	if (!L.elem || !L.before)
		return;
	L.length = 0;
}

void get_num(Sqlist& L, int n)
{
	int input = 0;
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &input);
		L.elem[i] = input;
		L.before[i] = input;
		L.length++;
	}
}

int my_delete(Sqlist& L, int local)
{
	if (local<1 || local>L.length)
	{
		return 0;
	}
	int i = 0;
	for (i = local; i < L.length; i++)
	{
		L.elem[i - 1] = L.elem[i];
	}
	L.length--;
	return 2;
}

void print(Sqlist L, int n,int x)
{
	printf("Before:(%d", L.before[0]);
	for (int i = 1; i < n; i++)
	{
		printf(",%d", L.before[i]);
	}
	printf(")\n");
	if (x == 0)
	{
		printf("Insert position error!");
		return;
	}
	printf("After:(%d", L.elem[0]);
	for (int j = 1; j < L.length; j++)
	{
		printf(",%d", L.elem[j]);
	}
	printf(")\n");
}

int main()
{
	int n = 0;
	Sqlist L;
	scanf("%d", &n);
	Init(L);
	get_num(L, n);
	int local = 0;
	int value = 0;
	scanf("%d", &local);
	int x = my_delete(L, local);
	print(L, n, x);
	return 0;
	printf("\n");
}